/**
 * 工具函数
 */


//手机号
let utils = {}
utils.tell = function (tell) {
    let reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
    return reg.test(tell);
}


//密码
utils.pwdreg = function (pwd) {
    let pwdreg = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]{6,20})$/;
    return pwdreg.test(pwd);
}

/**
 * @addFooter  页面的底部导航
 * @page 当前页面
 */
utils.addFooter = function () {
    let footer = document.createElement('footer');
    let html = `
        <div class="box1">
            <a href="./home.html">
                <i class="iconfont icon-zhuye home"></i>
                <div class="icon-text home">首页</div>
            </a>
        </div>
        <div class="box1">
            <a href="./sports.html">
                    <i class="iconfont icon-jiankangshuju sport"></i>
                    <div class="icon-text sport">运动</div>
            </a>
        </div>
        <div class="box1">
            <a href="./about.html">
                    <i class="iconfont icon-wode1 about"></i>
                    <div class="icon-text about">我的</div>
            </a>
        </div>
        `
    footer.innerHTML = html;
    document.querySelector('body').appendChild(footer);
}

//弹出提示框
let toast = document.querySelector('.toast')
utils.show = function (state, str) {
    toast.style.display = 'block'
    if (state == 1) {
        toast.innerHTML = `<i class="iconfont icon-shibai"></i><div>${str}</div>`
    }else{
        toast.innerHTML = `<i class="iconfont icon-chenggong"></i><div>${str}</div>`
    }
    setTimeout(function () {
        toast.innerHTM = ''
        toast.style.display = 'none'
    }, 2000)
}


window.utils = utils